package com.lizhi.menu.controller;

import com.lizhi.menu.common.response.Result;
import com.lizhi.menu.domain.MenuComment;
import com.lizhi.menu.service.IMenuCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 食谱评论Controller
 *
 * @author lizhi
 * @date 2023-05-18
 */
@RestController
@RequestMapping("/system/menucomment")
@RequiredArgsConstructor
@Api(tags = "食谱评论管理")
public class MenuCommentController {
    private final IMenuCommentService menuCommentService;

    /**
     * 查询食谱评论列表
     */
    @GetMapping("/list")
    @ApiOperation("查询食谱评论列表")
    public Result<List<MenuComment>> list(MenuComment menuComment) {
        List<MenuComment> list = menuCommentService.selectMenuCommentList(menuComment);
        return Result.ok(list);
    }

    /**
     * 获取食谱评论详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("获取食谱评论详细信息")
    public Result<MenuComment> getInfo(@PathVariable("id") Long id) {
        return Result.ok(new MenuComment().selectById(id));
    }

    /**
     * 新增食谱评论
     */
    @PostMapping
    @ApiOperation("新增食谱评论")
    public Result<Void> add(@RequestBody MenuComment menuComment) {
        menuCommentService.insertMenuComment(menuComment);
        return Result.ok();
    }

    /**
     * 修改食谱评论
     */
    @PutMapping
    @ApiOperation("修改食谱评论")
    public Result<Void> edit(@RequestBody MenuComment menuComment) {
        menuCommentService.updateMenuComment(menuComment);
        return Result.ok();
    }

    /**
     * 删除食谱评论
     */
    @DeleteMapping("/{ids}")
    @ApiOperation("删除食谱评论")
    public Result<Void> remove(@PathVariable Long[] ids) {
        menuCommentService.deleteMenuCommentByIds(ids);
        return Result.ok();
    }
}
